<%@ page pageEncoding="utf-8"%> 
<%@page import="com.course.db.*"%>

<%  
	request.setCharacterEncoding("utf-8");
	request.setAttribute("layout","main.jsp");
	request.setAttribute("page_title","温岭选课系统-课程列表");
	String path = request.getContextPath();  
	String basePath = request.getScheme()+"://"+request.getServerName()+
		(request.getServerPort() == 80 ? "" : (":"+request.getServerPort())) +path+"/";  
	String   userName   =   (String)session.getAttribute("userName");
	String   userType   =   (String)session.getAttribute("userType");
	String 	 menus=(String)session.getAttribute("menus");
%>

<script type="text/javascript">
	var base_path = "<%=basePath%>";
	var user_name="<%=userName%>";
	var user_type="<%=userType%>";
	var menus="<%=menus%>";

	function closebox(){ 
		   this.parent.Popup.prototype.reset_m(); //会刷新父页面
	}
	
	function editpwd(){
		   $.ajax({
				url: base_path+"Student/editPwd.do?type=student",
				type: "POST",
	            data: {"prepwd":$("#prepwd").val(),"password":$("#pwd").val(),"mkpwd":$("#mkpwd").val()}, 
				beforeSend: function(XMLHttpRequest){
					if($("#pwd").val() != $("#mkpwd").val())
						{
							alert("两次输入的密码不一致，请重新输入！");
							document.getElementById("pwd").value = "";
							document.getElementById("mkpwd").value = "";
							return false;
						}
				},
				success: function(data, textStatus){
					if(data=="success"){
						alert("密码修改成功，请用新密码重新登录！");
						logout();
					}else{
						alert("原密码输入不正确，请重新输入！");
						document.getElementById("prepwd").value = "";
					}
				},

				complete: function(XMLHttpRequest, textStatus){
				
				},
				error: function(){
					$("#ajaxResult").html("服务器异常，请联系网络管理员");
				}
			});
	   }
	
	function reset()
	{
		document.getElementById("prepwd").value = "";
		document.getElementById("pwd").value = "";
		document.getElementById("mkpwd").value = "";
	}
</script>
<base href="<%=basePath%>">
<%
	request.setAttribute("page_title","温岭选课系统-课程申报详细");
%>
<link rel="stylesheet" href="css/text.css" />
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/style.css" />
<style>
	table{
		margin:0;
		padding:0;
		border-collapse:collapse;
		border:0;
		cellpadding:0;
		cellspacing:0; 
		width:100%;
		//height:100%;
	}
	
	td{
		text-align:center;
		vertical-align:middle;
		line-height:30px;
		font-size:13px;
		border-collapse:collapse;
		border:1px solid black;
		margin:0;
		padding:0;
		
	}

	.tdLeft{
		align:left;
		text-align:left;
		padding-left:20px;
		
	}
</style>

	
<div style="width:100%; margin:1px;text-align:center;margin-top:10px;margin-bottom:50px;">
 	<p style="border:0;font-size:14px;margin-top:20px;padding-bottom:20px;">
  		<b>修改密码</b>
	</p>
		<table style="border:1px solid gray;margin-left:30%;width:40%;">
			<tr>
				<td>原密码</td><td align=left><input size=20 type="password" name="prepwd" id="prepwd"></td>
			</tr>
			<tr>
				<td>新密码</td><td align=left><input size=20 type="password" name="password" id="pwd"></td>
			</tr>
			<tr>
				<td>确认密码</td><td align=left><input size=20 type="password" name="mkpwd" id="mkpwd"></td>
			</tr>
		</table>
		<div id="btn"  style="margin-left:40%;width:40%;">
			<a href="javascript:editpwd();" >确认</a>
			<a href="javascript:reset(-1);">清空</a>
		</div>
</div>